using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace Test2.Models.Mapping
{
    public class JumpMap : EntityTypeConfiguration<Jump>
    {
        public JumpMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            this.Property(t => t.Id)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            // Table & Column Mappings
            this.ToTable("Jumps");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.Height).HasColumnName("Height");
            this.Property(t => t.DiverId).HasColumnName("DiverId");
            this.Property(t => t.DiveType).HasColumnName("Type");

            // Relationships
            this.HasRequired(t => t.Diver)
                .WithMany(t => t.Jumps)
                .HasForeignKey(d => d.DiverId);
        }
    }
}
